package com.tjvib.bean;

import com.tjvib.util.LogUtil;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class DataSetInfo {

    private long id;

    private String name;

    private String type;

    private boolean analyzable;

    private String timestamp;

    public DataSetInfo(long id, String name, String type, boolean analyzable, String timestamp) {
        this.id = id;
        this.name = name;
        this.type = type;
        this.analyzable = analyzable;
        this.timestamp = timestamp;
    }

    public DataSetInfo(String json) throws JSONException {
        JSONObject jsonObject = new JSONObject(json);
        id = jsonObject.getLong("id");
        name = jsonObject.getString("name");
        type = jsonObject.getString("type");
        analyzable = jsonObject.getBoolean("analyzable");
        timestamp = jsonObject.getString("timestamp");
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean isAnalyzable() {
        return analyzable;
    }

    public void setAnalyzable(boolean analyzable) {
        this.analyzable = analyzable;
    }

    public String getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(String timestamp) {
        this.timestamp = timestamp;
    }

    public JSONObject toJsonObject() throws JSONException {
        JSONObject result = new JSONObject();
        result.put("id", id);
        result.put("name", name);
        result.put("type", type);
        result.put("analyzable", analyzable);
        result.put("timestamp", timestamp);
        return result;
    }

    public Map<String, String> toMap() {
        Map<String, String> result = new HashMap<>();
        result.put("id", String.valueOf(id));
        result.put("name", name);
        result.put("type", type);
        result.put("analyzable", String.valueOf(analyzable));
        result.put("timestamp", timestamp);
        return result;
    }
}
